function Kursanci() {
	return  {
		createListFromJsonArray: function(jsonData, listId) {
			var html ='';
		    $.each(jsonData, function(index, item) {
		        html += '<li data-theme="d" data-split-icon="gear" data-split-theme="d" >'
		        html += '<a href="#" id="showKursant" name="' + item.id  + '" onClick="javascript: new Kursanci().openShowWindow(' + item.id + ')">';
		        html += '<h3>' + item.imie + ' ' + item.nazwisko + '</h3>'
		        html += '<p>Godziny jazdy: <strong>' + item.godzJazdy + '</strong></p>'
		        html += '<p>Godziny wykładów: <strong>' + item.godzWykladu + '</strong></p>'
		        html += '<p class="ui-li-aside">Data urodzenia: <strong>' + item.dataUrodzin + '</strong></p>'
		        html += '</a><a href="#" data-icon="edit" data-position-to="window" name="' + item.id  + '" onClick="javascript: new Kursanci().openChangeHoursWindow(' + item.id + ')"></a></li>';
		    });
		    
		   $('#' + listId).empty();
		   $('#' + listId).append($(html));
		   $('#' + listId).trigger('create');
		   $('#' + listId).listview('refresh');
		},
		openShowWindow : function(kursantId) {
			App.doGetRequestJson({
				url: 'kursant!showKursant.action?kursantId=' + kursantId,
				onSucces: function(response) {
					var valueKatA = "nie";
					if(response[0].katA == true){
						valueKatA = "tak";
					}
					var valueKatB = "nie";
					if(response[0].katB == true){
						valueKatB = "tak";
					}
					
					var imie2 = "-";
					if(response[0].imie2 != ""){
						imie2 = response[0].imie2;
					}
					
					var uwagi = "-";
					if(response[0].uwagi != ""){
						uwagi = response[0].uwagi;
					}
					
					var html = '<div style="margin: 20px;"><h2>' + response[0].imie + ' '+ response[0].nazwisko +'</h2>'
						+ '<p> LOGIN: <strong>' + response[0].login +'</strong></p>'
						+ '<p> DRUGIE IMIĘ: <strong>' + imie2 +'</strong></p>'
						+ '<p> EMAIL: <strong>' + response[0].email +'</strong></p>'
						+ '<p> DATA URODZENIA: <strong>' + response[0].dataUrodzin +'</strong></p>'
						+ '<p> PESEL: <strong>' + response[0].pesel +'</strong></p>'
						+ '<p> TELEFON: <strong>' + response[0].telefon +'</strong></p>'
						+ '<p> KATEGORIA A: <strong>' + valueKatA +'</strong></p>'
						+ '<p> KATEGORIA B: <strong>' + valueKatB +'</strong></p>'
						+ '<p> UWAGI: <strong>' + uwagi +'</strong></p>'
						+ '<br><center><a href="#" rel="close" data-icon="check" data-role="button">OK</a></center></div>';
					
					
					$('<div>').simpledialog2({
						mode: 'blank',
						headerText: 'Kursant',
						headerClose: true,
						blankContent: html,
						width: '400px'
			  		})
				}
			});	
		},
		openChangeHoursWindow : function(kursantId) {
			App.doGetRequestText({
				url: 'kursant!editGodziny.action?kursantId=' + kursantId,
				onSucces: function(response) {
					$('<div>').simpledialog2({
						mode: 'blank',
						headerText: 'Godziny kursu',
						headerClose: true,
						blankContent: response.replace(/\\n/g, ''),
						width: '300px'
			  		});
				}
			});
		}
	}
};
